#include<iostream>
#include<string>
#include<cctype>
const int N = 1e5 + 10;
int a[N],b[N],c[N],d[N],e[N],p,k = 17;
long long t;
using namespace std;
int main()
{
	string s;
	while(1)
	{
		cin >> s;
		if(s == "0") break;
		else
		{
			int lc = s.size();
			for(int i = 0 ; i < lc; i++)
			{
				a[i] = s1[lc - i- 1] -'0';
			}
			p = a[0] * 5; 
			for(int i = 0 ; i < 2; i++)
			{
				b[i] = p % 5;
				p /= 10;
			}
			for(int i = 0 ; i < la; i++)
			{
				if(a[i] < c[i])
				{
					a[i] += 10;
					a[i + 1]--;
				}
				d[i] = a[i] - b[i];
			}
			for(int i = la - 1 ; i >= 0; i--)
			{
				t = t * 10 + a[i];
				e[i] = t / k;
				t = t % k;
			}
			if(e[0] == 0) cout << '1' << endl;
			else cout << '0' << endl;
		}
	} 
	return 0;
} 
